<?php
class ModelCatalogDownload extends Model {
    public function getDownload($download_id) {
        $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE d.download_id = '" . (int)$download_id . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "'");

        return $query->row;
    }

    public function getDownloadDescriptions($download_id) {
        $download_description_data = array();

        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");

        foreach ($query->rows as $result) {
            $download_description_data[$result['language_id']] = array('name' => $result['name']);
        }

        return $download_description_data;
    }

    public function getTotalDownloads() {
        $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "download");

        return $query->row['total'];
    }
}